const WebSocket = require('ws'); 
const wss = new WebSocket.Server({ port: 8102 }); 
wss.on('connection', function connection(ws) { 
  ws.on('message', function incoming(message) {
    // 当服务器接收到客户端发来的消息时触发
    console.log('received: %s', message);
  }); 
  ws.send('something');
});
 
console.log('WebSocket server is running on ws://localhost:3000');

